#include <QApplication>
#include <QWidget>
#include <QLayout>

#include "testwidget.h"

#include "log4qt/logger.h"
#include "log4qt/consoleappender.h"
#include "log4qt/ttcclayout.h"
#include "log4qt/logmanager.h"

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    
    auto logger = Log4Qt::Logger::rootLogger();
    auto* layout = new Log4Qt::TTCCLayout();
    layout->setName(QStringLiteral("My Layout"));
    layout->activateOptions();
    // Create a console appender
    Log4Qt::ConsoleAppender* consoleAppender = new Log4Qt::ConsoleAppender(layout, Log4Qt::ConsoleAppender::STDOUT_TARGET);
    consoleAppender->setName(QStringLiteral("My Appender"));
    consoleAppender->activateOptions();
    // Add appender on root logger
    logger->addAppender(consoleAppender);
    // Set level to info
    logger->setLevel(Log4Qt::Level::DEBUG_INT);
    // Enable handling of Qt messages
    Log4Qt::LogManager::setHandleQtMessages(true);

    logger->info(QStringLiteral("################################################################"));
    logger->info(QStringLiteral("#                          START                               #"));
    logger->info(QStringLiteral("################################################################"));

    TestWidget widget;
    widget.show();
    return app.exec();
}
